#include "MainMenu.hh"
#include "../Utils/sources/Common.cpp"
#include "Game.hh"
#include <iostream>
#include <thread>
#include <chrono>
#include <vector>

using namespace std;

// 获取用户选择的菜单选项
MenuChoice Menu::getChoice() {
    Utility::clearScreen();
    showMainMenu();

    string choice;
    getline(cin, choice);

    if (choice == "1") return NEW_GAME;
    if (choice == "2") return LOAD_GAME;
    if (choice == "3") return HELP;
    if (choice == "4") return EXIT;
    return INVALID;
}

// 显示主菜单界面
void Menu::showMainMenu() {
    showTitle("CHU-Rogue");

    cout << "1. New Game" << endl;
    cout << "2. Load Game" << endl;
    cout << "3. Help" << endl;
    cout << "4. Exit" << endl;
    cout << "PRESS(1-4):";
}

// 显示帮助信息
void Menu::showHelp() {
    Utility::clearScreen();
    showTitle("Game Instructions");

    // 帮助内容
    vector<string> content = {
        "This is a text-based RPG game developed in C++.",
        "Players can explore rooms, collect items, fight enemies, and ultimately win.",
        "Gameplay: Enter the corresponding number according to the menu prompts.",
        "Remember, magic will refresh your inventory and room every time you exit and re-enter the world.",
        "This magic_world looks Unstable,Seems like it will crash anytime",
        "Try to clear the level in one go !!",
        "",
        "",
        "",
        "",
        "",
        "",
        "what are you waiting for ? Go and play this fucking stupid game!",
        "███████╗ ██╗   ██╗ ██████╗   ██╗  ██╗",
        "██╔════╝ ██║   ██║██╔═══██╗  ██║ ██╔╝",
        "█████╗   ██║   ██║██║        █████╔╝ ",
        "██╔══╝   ██║   ██║██║        ██╔═██╗ ",
        "██║      ╚██████╔╝╚██████╗   ██║  ██╗",
        "╚═╝       ╚═════╝  ╚═════╝   ╚═╝  ╚═╝",
    };

    // 逐行显示帮助内容
    for (const auto& line : content) {
        cout << line << endl;
        this_thread::sleep_for(chrono::seconds(1));
    }

    Utility::pause();
}

// 显示退出信息
void Menu::showExitMessage() {
    Utility::clearScreen();
    cout << "Thank you for playing, goodbye!" << endl;
}

// 显示标题
void Menu::showTitle(const string& title) {
    cout << "======== " << title << " ========\n" << endl;
}
